///API返回数据解析类
///孙焰明创建
class ClassResponseData {
  final String status;
  final _Data data;

  ClassResponseData.fromJson(Map<String, dynamic> json)
      : status = json['status'],
        data = _Data.fromJson(json['data']);

  Map<String, dynamic> toJson() => {
        'status': status,
        'data': data.toJson(),
      };
}

class _Data {
  final List<_ClassInfo> result;

  _Data.fromJson(Map<String, dynamic> json)
      : result = (json['result'] as List)
            .map((e) => _ClassInfo.fromJson(e))
            .toList();

  Map<String, dynamic> toJson() => {
        'result': result.map((e) => e.toJson()).toList(),
      };
}

class _ClassInfo {
  final String _id;
  final _CourseId course_id;
  final String lesson_id;
  final _TeacherId teacher_id;
  final List<_ADayClassInfo> curriculum;
  final int __v;
  final int semester;
  final String year;

  _ClassInfo.fromJson(Map<String, dynamic> json)
      : _id = json['_id'],
        course_id = _CourseId.fromJson(json['course_id']),
        lesson_id = json['lesson_id'],
        teacher_id = _TeacherId.fromJson(json['teacher_id']),
        curriculum = (json['curriculum'] as List)
            .map((e) => _ADayClassInfo.fromJson(e))
            .toList(),
        __v = json['__v'],
        semester = json['semester'],
        year = json['year'];

  Map<String, dynamic> toJson() => {
        '_id': _id,
        'course_id': course_id.toJson(),
        'lesson_id': lesson_id,
        'teacher_id': teacher_id.toJson(),
        'curriculum': curriculum.map((e) => e.toJson()).toList(),
        '__v': __v,
        'semester': semester,
        'year': year,
      };
}

class _CourseId {
  final String id;
  final String name;

  _CourseId.fromJson(Map<String, dynamic> json)
      : id = json['id'],
        name = json['name'];

  Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
      };
}

class _TeacherId {
  final String id;
  final String name;

  _TeacherId.fromJson(Map<String, dynamic> json)
      : id = json['id'],
        name = json['name'];

  Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
      };
}

class _ADayClassInfo {
  final List<String> order;
  final int odd_or_even;
  final _ClassId class_id;
  final _RoomId room_id;
  final String date;

  _ADayClassInfo.fromJson(Map<String, dynamic> json)
      : order = (json['order'] as List).map((e) => e.toString()).toList(),
        odd_or_even = json['odd_or_even'],
        class_id = _ClassId.fromJson(json['class_id']),
        room_id = _RoomId.fromJson(json['room_id']),
        date = json['date'];

  Map<String, dynamic> toJson() => {
        'order': order,
        'odd_or_even': odd_or_even,
        'class_id': class_id.toJson(),
        'room_id': room_id.toJson(),
        'date': date,
      };
}

class _ClassId {
  final String class_name;
  final String id;

  _ClassId.fromJson(Map<String, dynamic> json)
      : class_name = json['class_name'],
        id = json['id'];

  Map<String, dynamic> toJson() => {
        'class_name': class_name,
        'id': id,
      };
}

class _RoomId {
  final String room_name;
  final int room_size;
  final String room_status;
  final String _id;
  final int room_number;
  final String room_type;
  final String building_name;
  final String campus_name;
  final String org_name;
  final List<String> room_users;
  final int __v;
  final String living_lessonID;
  final String deviceBoxIP;

  _RoomId.fromJson(Map<String, dynamic> json)
      : room_name = json['room_name'],
        room_size = json['room_size'],
        room_status = json['room_status'],
        _id = json['_id'],
        room_number = json['room_number'],
        room_type = json['room_type'],
        building_name = json['building_name'],
        campus_name = json['campus_name'],
        org_name = json['org_name'],
        room_users =
            (json['room_users'] as List).map((e) => e.toString()).toList(),
        __v = json['__v'],
        living_lessonID = json['living_lessonID'],
        deviceBoxIP = json['deviceBoxIP'];

  Map<String, dynamic> toJson() => {
        'room_name': room_name,
        'room_size': room_size,
        'room_status': room_status,
        '_id': _id,
        'room_number': room_number,
        'room_type': room_type,
        'building_name': building_name,
        'campus_name': campus_name,
        'org_name': org_name,
        'room_users': room_users,
        '__v': __v,
        'living_lessonID': living_lessonID,
        'deviceBoxIP': deviceBoxIP,
      };
}
